package cn.mysdp.biz.facade;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import cn.mysdp.biz.dto.request.*;
import cn.mysdp.biz.dto.response.*;
import cn.mysdp.biz.domain.*;
import cn.mysdp.biz.facade.*;
import cn.mysdp.biz.facade.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: SdpTemplateFacadeImpl
 * @Description:
 * @Author: SDP
 * @Date: 2021-10-30
 * @Version: 1.0
 * Table: sdp_template
 * Comment:
 * 
 */
@Service
public class SdpTemplateFacadeImpl extends SdpTemplateFacadeCustomImpl implements SdpTemplateFacade {

    static {
        beanClassNameMap.put("sdp_template", "sdpTemplateFacadeImpl");
        listMethodNameMap.put("sdp_template", "listSdpTemplate");
        listMethodParameterClassNameMap.put("sdp_template", "SdpTemplateQueryRequest");
        updateMethodNameMap.put("sdp_template", "updateSdpTemplate");
        updateMethodParameterClassNameMap.put("sdp_template", "SdpTemplateUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addSdpTemplate(SdpTemplateAddRequest request) throws Exception {
        super.fixRequest("sdp_template", "add", request);
        return super.addSdpTemplate(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateSdpTemplate(SdpTemplateUpdateRequest request) throws Exception {
        SdpTemplate record = null;
        record = sdpTemplateMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("sdp_template", "update", request, record);
        return super.updateSdpTemplate(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteSdpTemplate(SdpTemplateDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<SdpTemplate> list = null;
            SdpTemplateExample example = new SdpTemplateExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = sdpTemplateMapper.selectByExample(example);
            fixRequest("sdp_template", "delete", request, list);
        } else {
            fixRequest("sdp_template", "delete", request);
        }
        return super.deleteSdpTemplate(request);
    }

    @Override
    public SdpTemplateQueryResponse querySdpTemplate(SdpTemplateQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        SdpTemplateQueryResponse result = super.querySdpTemplate(request);
        checkResult("sdp_template", "query", request, result);
        return result;
    }

    @Override
    public List<SdpTemplateQueryResponse> listSdpTemplate(SdpTemplateQueryRequest request) throws Exception {
        List<SdpTemplateQueryResponse> list = super.listSdpTemplate(request);
        checkResult("sdp_template", "list", request, list);
        return list;
    }

    @Override
    public Integer countSdpTemplate(SdpTemplateQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_template", "count", request);
        return super.countSdpTemplate(request);
    }

    @Override
    public BaseStatResponse statSdpTemplate(SdpTemplateQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_template", "stat", request);
        return super.statSdpTemplate(request);
    }

}
